package Model

import "time"

type Paycheck struct {
	itsPayPeriodStartDate time.Time
	itsPayPeriodEndDate   time.Time
	itsGrossPay           float64
	itsNetPay             float64
	itsDeductions         float64
	itsFields             map[string]string
}

// func (p *Paycheck) Paycheck(payPeriodStart time.Time, payPeriodEnd time.Time) {
// 	// 先这么写，不行再换成工厂函数
// 	p.itsPayPeriodStartDate = payPeriodStart
// 	p.itsPayPeriodEndDate = payPeriodEnd
// }

func NewPaycheck(payPeriodStart time.Time, payPeriodEnd time.Time)*Paycheck{
	return &Paycheck{
		payPeriodStart,
		payPeriodEnd,
		0,0,0,nil,
	}
}

func (p *Paycheck) SetGrossPay(grossPay float64) {
	p.itsGrossPay = grossPay
}

func (p *Paycheck) SetDeductions(deductions float64) {
	p.itsDeductions = deductions
}

func (p *Paycheck) SetNetPay(netPay float64) {
	p.itsNetPay = netPay
}

func (p *Paycheck) GetPayPeriodEndDate() time.Time {
	return p.itsPayPeriodEndDate
}

func (p *Paycheck) GetGrossPay() float64 {
	return p.itsGrossPay
}

func (p *Paycheck) GetField(name string) string {
	return p.itsFields[name]
}

func (p *Paycheck) GetDeductions() float64 {
	return p.itsDeductions
}

func (p *Paycheck) GetNetPay() float64 {
	return p.itsNetPay
}

func (p *Paycheck) SetField(name string, value string) {
	p.itsFields[name] = value
}

func (p *Paycheck) GetPayPeriodStartDate() time.Time {
	return p.itsPayPeriodStartDate
}
